import Vue from "vue";
import axios from "./router/axios";
import VueAxios from "vue-axios";
import App from "./App";
import router from "./router/router";
import "./permission"; // 权限
import "./error"; // 日志
import "./cache"; //页面缓存
import store from "./store";
import { loadStyle } from "./util/util";
import * as urls from "@/config/env";
import Element from "element-ui";
import { iconfontUrl, iconfontVersion } from "@/config/env";
import i18n from "./lang"; // 中英文国际化模式
import "./styles/common.scss";

import "./assets/iconfont/iconfont.css";
import "./assets/css/style.css";

import basicBlock from "./components/basic-block/main";
import basicContainer from "./components/basic-container/main";
import thirdRegister from "./components/third-register/main";
import avueUeditor from "avue-plugin-ueditor";
import website from "@/config/website";
import echarts from "echarts";
import avueMap from "./components/map/main.vue"

import VueAMap from "vue-amap";
Vue.use(VueAMap);
// 初始化vue-amap
VueAMap.initAMapApiLoader({
  key: "54d610bdfdd452b78c206bf1ac1755d8", // 高德的key
  // 插件集合
  plugin: [
    "AMap.CircleEditor", // 圆形编辑器插件
    "AMap.Geolocation", // 定位控件，用来获取和展示用户主机所在的经纬度位置
    "AMap.Geocoder", // 地理编码与逆地理编码服务，用于地址描述与坐标间的相互转换
    "AMap.Autocomplete",
    "AMap.PlaceSearch",
    "AMap.CitySearch",
  ],
  // 高德 sdk 版本，默认为 1.4.4
  v: "1.4.11",
});

import Print from "@/util/print"; // 引入附件的js文件

Vue.use(Print);

Vue.use(router);
Vue.use(VueAxios, axios);

//elementUI全局设置弹框默认点击遮罩层不关闭
Element.Dialog.props.closeOnClickModal.default = false;

Vue.use(Element, {
  size: "small",
  zIndex: 3000,
  i18n: (key, value) => i18n.t(key, value),
});

Vue.use(window.AVUE, {
  size: "small",
  tableSize: "small",
  i18n: (key, value) => i18n.t(key, value),
});

Vue.prototype.$echarts = echarts;

//注册全局容器
Vue.component("basicContainer", basicContainer);
Vue.component("basicBlock", basicBlock);
Vue.component("thirdRegister", thirdRegister);
Vue.component("avueUeditor", avueUeditor);
Vue.component('AvueMap', avueMap);
// 加载相关url地址
Object.keys(urls).forEach((key) => {
  Vue.prototype[key] = urls[key];
});
// 加载website
Vue.prototype.website = website;
// 动态加载阿里云字体库
iconfontVersion.forEach((ele) => {
  loadStyle(iconfontUrl.replace("$key", ele));
});
Vue.config.productionTip = false;
Vue.config.devtools = true;
new Vue({
  router,
  store,
  i18n,
  render: (h) => h(App),
}).$mount("#app");
